#ifndef VECTOR3D_H
#define VECTOR3D_H
#include "stdafx.h"
using namespace std;

class Vector_3D
{
public:
	friend inline ostream& operator<<(ostream& out, const Vector_3D& vec)
	{
		out<<setprecision(6)<<setw(12)<<vec.x<<setw(12)<<vec.y<<setw(12)<<vec.z<<endl;
		return out;
	}
	Vector_3D (double _a=0,double _b=0,double _c=0)
	{
		x=_a;
		y=_b;
		z=_c;
	}
	Vector_3D(const Vector_3D& two)
	{
		x=two.x;
		y=two.y;
		z=two.z;
	}
	Vector_3D operator-()
	{
		Vector_3D c(-x,-y,-z);
		return c;
	}
	Vector_3D& operator=(const Vector_3D& two)
	{
		if(this!=&two)
		{
			x=two.x;
			y=two.y;
			z=two.z;
		}
		return *this;
	}
	Vector_3D& operator+=(const Vector_3D& two)
	{
		if(this != &two)
		{
			x += two.x;
			y += two.y;
			z += two.z;
		}
		return *this;
	}
	Vector_3D& operator-=(const Vector_3D& two)
	{
		if(this != &two)
		{
			x -= two.x;
			y -= two.y;
			z -= two.z;
		}
		return *this;
	}
	inline Vector_3D operator+(const Vector_3D& one)
	{
		double x1=x+one.x;
		double y1=y+one.y;
		double z1=z+one.z;
		return Vector_3D(x1,y1,z1);
	}
	inline Vector_3D operator-(const Vector_3D& one)
	{
		double x1=x-one.x;
		double y1=y-one.y;
		double z1=z-one.z;
		return Vector_3D(x1,y1,z1);
	}
	inline Vector_3D operator*(const double scalar)
	{
		double x1=x*scalar;
		double y1=y*scalar;
		double z1=z*scalar;
		return Vector_3D(x1,y1,z1);
	}
	inline Vector_3D operator/(const double scalar)
	{
		double x1=x/scalar;
		double y1=y/scalar;
		double z1=z/scalar;
		return Vector_3D(x1,y1,z1);
	}
	inline double norm() const
	{
		return sqrt(x*x+y*y+z*z);
	}

	double x;
	double y;
	double z;
};

#endif


